import { type Ref, ref, h } from "vue";
import type { PlusColumn, OptionsRow, RecordType } from "plus-pro-components";
import { getTaskAssignments } from "@/api/zhaoyuan";
import { ElTimeline, ElTimelineItem } from "element-plus";
export function useDetail() {
  const detailColumns: PlusColumn[] = [
    {
      label: "截止日期",
      width: 120,
      prop: "task.deadline"
    },
    {
      label: "状态",
      width: 120,
      prop: "status"
    },
    {
      label: "优先级",
      width: 120,
      prop: "task.priority"
    },
    {
      label: "分配时间",
      width: 120,
      prop: "assignedDate"
    },
    {
      label: "任务进度",
      width: 120,
      prop: "progressNotes"
    },
    {
      label: "创建时间",
      width: 120,
      prop: "task.createdDate",
      valueType: "date-picker"
    },
    {
      label: "任务标题",
      width: 120,
      prop: "task.title"
    },
    {
      label: "任务描述",
      width: 120,
      prop: "task.description"
    },
    {
      label: "工作类型",
      width: 120,
      prop: "task.dutyType"
    },
    {
      label: "任务类型",
      width: 120,
      prop: "task.taskType"
    },
    {
      label: "任务进度",
      width: 120,
      prop: "processes"
    }
  ];
  const detailData = ref<RecordType>({});
  const detailVisible = ref(false);

  const detailOpen = (row: any = {}) => {
    getTaskAssignments(row.id).then(res => {
      detailData.value = res;
    });
    detailVisible.value = true;
  };

  return {
    detailColumns,
    detailVisible,
    detailData,
    detailOpen
  };
}
